global  hleftaxes hrightaxes M1 lS1 lP1 ycor  ind1 sqrx sqry h0 tdjr tdjc Tdtc ostyp genecell hwww x 
global leng hc hd index1 index2 b0 hmessageso hmessagesu hmessagesod hmessagesud intercept1 intercept2 filename3 ind1
set(get(hleftaxes,'Children'),'ButtonDownFcn','slctsptdragstop');
set(get(hrightaxes,'Children'),'ButtonDownFcn','slctscttrdrag');
if (exist('hc2w'))
     delete(hc2w);
     clear hc2w;
end
if (exist('htxt'))
     delete(htxt);
     clear htxt;
end
	
axes(hleftaxes)
     hold on
if exist('hleftsquare')
  set(hleftsquare, 'Color', [0 1 0], 'Linewidth', 2);
end
%changed jbw
hleftsquare=plot(sqrx+M1(ind1,6),sqry+M1(ind1,5),'r-','linewidth',2);

%set(hleftsquare, 'ButtonDownFcn', 'slctsptdragstop');
     hold off

axes(hrightaxes);
     hold on
if exist('hspot')
  %delete(hspot);
  %holdspot = plot(oldspt(1), oldspt(2),'co');
  set(hspot,'Color', [0 1 0], 'Linewidth', 2);
     end
hspot = plot(lS1(ind1),lP1(ind1),'ro','linewidth',2);
   %set(hspot,'ButtonDownFcn', 'slctscttrdrag');
%oldspt = [lS1(ind1),lP1(ind1)];
     hold off
     if (exist('hsmallaxes'))
       delete(hsmallaxes);
       clear hsmallaxes;
     end
     hsmallaxes = axes('Parent',h0, ...
        'units','normalized', ...
	'CameraUpVector',[0 1 0], ...
	'CameraUpVectorMode','manual', ...
	'Color',[1 1 1], ...
	'Position',[0.0193 .0276 .3 .3], ...
	'Tag','Axess', ...
	'XColor',[0 0 0], ...
	'YColor',[0 0 0], ...
	'ZColor',[0 0 0]);

     axes(hsmallaxes);
     context = max([sqrx sqry]) + 1;
     temp1 = Tdtc(max([round(M1(ind1,5)-context),1]):min([round(M1(ind1,5)+context),tdjr]), ...
                  max([round(M1(ind1,6)-context),1]):min([round(M1(ind1,6)+context),tdjc]),1);
     temp2 = Tdtc(max([round(M1(ind1,5)-context),1]):min([round(M1(ind1,5)+context),tdjr]), ...
                  max([round(M1(ind1,6)-context),1]):min([round(M1(ind1,6)+context),tdjc]),2);
     Tdsub = cat(3,temp1,temp2,zeros(size(temp1)));
     image(Tdsub);
     axis('image')
   %     axis([M1(ind1,6)-context M1(ind1,6)+context M1(ind1,5)-context M1(ind1,5)+context]);
     axis off
     hold on 
   %     hs=plot(cirx+M1(ind1,6),ciry+M1(ind1,5),'k-');
rowcorr = 1-max([M1(ind1,5)-context,1]);
colcorr = 1-max([M1(ind1,6)-context,1]);
   %     hs=plot(sqrx+M1(ind1,6),sqry+M1(ind1,5),'y-');
     hs=plot(sqrx+M1(ind1,6)+colcorr,sqry+M1(ind1,5)+rowcorr,'r-');
     set(hs,'LineWidth',2);
     hold off
     if (strcmp(ostyp,'MAC') > 0)
          % char(9) for tab; char(13) for MAC carriage return
          prntgene = strrep(genecell{ind1},char(9),[char(13) '     ']);
     else
     	  % char(9) for tab; char(10) for carriage return
          %added jbw
     	  prntgene = strrep(genecell{ind1},char(9),[char(10) '     ']);
     	  prntgene = [char(10) '   ' prntgene];
     end
   
%               'Callback','clone2web(genecell,indl,filename3);',...
htxt =    uicontrol('Parent',h0,...
		    'Units', 'normalized', ...
		    'Style', 'text', ...
		    'Position', [.55 .07  .4 .20], ...
		    'Backg', [1 1 1], ...
		    'Foreg', [0 0 0], ...
		    'String', prntgene, ...
		    'FontUnits', 'Normalized',...
		    'FontSize',  0.07, ...
		    'FontWeight',  'bold', ...
		    'HorizontalAlignment', 'left', ...
		    'Tag', 'genetext');

hc2w =    uicontrol('Parent',h0,...
		    'Units', 'normalized', ...
		    'Position', [.7 .01  .1 .05], ...
		    'Callback', 'clone2web(genecell,ind1,filename3);', ...
		    'String', 'WWW Clone', ...
		    'FontUnits', 'Normalized',...
		    'FontSize',  0.3, ...
		    'FontWeight',  'bold', ...
		    'Tag', 'c2w');
if (~exist('hwwwone'))
hwwwone =  uimenu(hwww,'Label','WWW show highlighted (red) gene','Callback','clone2web(genecell,ind1,filename3);');	
end
set(get(hleftaxes,'Children'),'ButtonDownFcn','slctsptdragstop');
set(get(hrightaxes,'Children'),'ButtonDownFcn','slctscttrdrag');
    %h1 = uicontrol('Parent',h0, ...
    %		    'Units','normalized', ...
    %		    'FontUnits','normalized', ...
    %		    'BackgroundColor',[0.7 0.7 0.7], ...
    %		    'FontSize',0.3, ...
    %		    'FontWeight','bold', ...
    %		    'ListboxTop',0, ...
    %		    'Position',[.3254 0.1022 0.125 0.1757], ...
    %		    'String','Filter List', ...
    %		    'Style','frame', ...
    %		    'Tag','Frame1');
    %h1 = uicontrol('Parent',h0, ...
    %		    'Units','normalized', ...
    %		    'FontUnits','normalized', ...
    %		    'BackgroundColor',[0.7 0.7 0.7], ...
    %		    'FontSize',0.6, ...
    %		    'FontWeight','bold', ...
    %		    'ListboxTop',0, ...
    %		    'Position',[0.34007 0.24 0.09283 0.0287], ...
    %		    'String','Filter List', ...
    %		    'Style','text', ...
    %		    'Tag','StaticText1');
    %h1 = uicontrol('Parent',h0, ...
    %		    'Units','normalized', ...
    %		    'FontUnits','normalized', ...
    %		    'FontSize',0.5, ...
    %		    'FontWeight','bold', ...
    %		    'ListboxTop',0, ...
    %		    'Position',[0.3474 0.20 0.079 0.0333], ...
    %		    'String','Include', ...
    %		    'Style','radiobutton', ...
    %		    'Tag','Radiobutton1');
    %h1 = uicontrol('Parent',h0, ...
    %		    'Units','normalized', ...
    %		    'FontUnits','normalized', ...
    %		    'FontSize',0.5, ...
    %		    'FontWeight','bold', ...
    %		    'ListboxTop',0, ...
    %		    'Position',[0.3474 0.16 0.079 0.0333], ...
    %		    'String','Exclude', ...
    %		    'Style','radiobutton', ...
    %		    'Tag','Radiobutton2');
    %h1 = uicontrol('Parent',h0, ...
    %		    'Units','normalized', ...
    %		    'FontUnits','normalized', ...
    %		    'FontSize',0.5, ...
    %		    'FontWeight','bold', ...
    %		    'ListboxTop',0, ...
    %		    'Position',[0.3474 0.12 0.079 0.0333], ...
    %		    'String','Reset', ...
    %		    'Tag','resetbutton');
